# Evolution simulation
This is a simulation of evolution written in C.
<br />
Probably works on all [operating systems supported by SDL2](https://wiki.libsdl.org/Installation), tested on Linux, Haiku and Emscripten(wasm, demo version)

# Keys
- R - enable/disable screen render
- S - save simulation
- K - reload simulation
- space - pause simulation
- F - enable/disable TPS(Tick per second)
- C - change color type
- - 1 - default, based on cell color attribute, 
- - 2 - based on type of food that cell eat(blue - minerals, green - sun, red - other cells/dead cells)
- - 3 - based on cell energy(A lot of energy - yellow, less - red)
- - 4 - based on cell age(old - green)
- D - Render next frame and pause

# Mouse
- Left button - Draw a wall
- Middle button - Print info about cell
- Right button - Eraser

# Compilation
### Dependencies
- SDL2
- SDL2 Net
- SDL2 TTF

### Building / Running
```sh
make
```
<br>
You will get 3 files in build directory, `life` is the main program, `mkworld` is simple tool to create worlds, `worlded` is the world editor that isn't done yet, but have some basic functions.
<br>
Then you should create a world using `mkworld`


```sh
./build/mkworld <width> <height> [output file]
```
<br>
As width and height you can use any value between 0 and 512, but I recommend something like 64 64.
<br><br>
Then, you can change some world params:

```sh
./build/worlded ./world.bin
> setfoodmaxage 500
> write
> quit
```
And running:

```sh
./build/life ./world.bin
```
Also, you can write some kind of scripts, for example look at the etc/ directory

# About portals
Portals require SDL net, and they provide a way to connect worlds, event between different computers. You just need simple server(see in etc/go_server), and run program with server IP as argument.

# Screenshots
![Default color mode](media/screenshot1.png)
![Energy color mode](media/screenshot2.png)
![Color mode based on type of food](media/screenshot3.jpg)
